package exchange

import (
	"github.com/parnurzeal/gorequest"
	"time"
	"global/core"
	"global/model"
	"global/libs/structs"
	"encoding/json"
)

type BitFinexSymbol struct {
	Client 		*gorequest.SuperAgent
	Ctx 		*core.Context
	exchange 	*model.Exchange
	ticker 		*time.Ticker
	coins 		map[string]int
	markets 	[]string
}

func NewBitfinexSymbol(
	ctx *core.Context,
	coins map[string]int,
	exchange *model.Exchange,
	)SymbolInterface {

	s := &BitFinexSymbol{
		Ctx: 		ctx,
		Client: 	gorequest.New(),
		exchange: 	exchange,
		ticker: 	time.NewTicker(1 * time.Minute),
		coins: 		coins,
	}
	s.markets = []string{"usd", "eur", "gbp", "jpy", "btc", "eth", "eos"}
	return s
}

func (s *BitFinexSymbol) Start()  {
	go func() {

	}()
}

func (s *BitFinexSymbol) handle() {


}

func (s *BitFinexSymbol) request() (map[string]*structs.Symbol, error) {
	_, body, errs := s.Client.Get(core.GetBitfinexV1Url("symbols")).End()
	if len(errs) > 0 {
		return nil, errs[0]
	}

	var symbols []string
	if err := json.Unmarshal([]byte(body), &symbols); err != nil {
		return nil, err
	}

	for _, v := range symbols {
		// todo
		_ = v
	}

	return nil, nil
}